﻿Public Class frmNgHis
    Private m_szLotNo As String
    Private m_szProcCD As String

    Public Sub New(ByVal szLotNo As String, ByVal szProcCD As String)

        ' この呼び出しはデザイナーで必要です。
        InitializeComponent()

        ' InitializeComponent() 呼び出しの後で初期化を追加します。
        m_szLotNo = szLotNo
        m_szProcCD = szProcCD
    End Sub

    Private Sub frmNgHis_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If String.IsNullOrEmpty(m_szLotNo) Then
            Exit Sub
        End If
        If String.IsNullOrEmpty(m_szProcCD) Then
            Exit Sub
        End If

        Dim cDbLotDf As New clsDbLotDefect
        Dim dtMold = cDbLotDf.GetMoldDefectData(m_szLotNo)
        Dim dtHis = cDbLotDf.GetDefectHis(m_szLotNo, m_szProcCD)

        Dim cnt As Integer = 0
        For Each row As DataRow In dtMold.Rows
            cnt += CInt(row("CAT_CNT"))
        Next
        lblTotal.Text = cnt
        dgvMold.DataSource = dtMold

        Dim iX As Integer = 0
        Dim iFx As Integer = 0
        Dim fAfterDB As Boolean = False
        For Each row As DataRow In dtHis.Rows
            If "4302".Equals(row("KOUTEI_CD")) Then
                fAfterDB = True
            End If
            If fAfterDB Then
                iX += CInt(row("CAT_CNT")) + CInt(row("cross_qty"))
                row("cross_qty") = iX
                iFx += CInt(row("cross_frmqty"))
                row("cross_frmqty") = iFx
            End If
        Next
        dgvHis.DataSource = dtHis
    End Sub
End Class